<template>
  <section class="app">
    <router-view></router-view>
  </section>
</template>

<script>
import { onMounted } from 'vue'
import JsBridge from '@/utils/JsBridge.js'

export default {
  setup(props) {

    onMounted(() => {
      JsBridge.callHandler('onLoadSucc', null, (res) => {

      })


      let isAndroid = navigator.userAgent.indexOf('Android') > -1 || navigator.userAgent.indexOf('Adr') > -1;
      if (isAndroid) {
        /**
         * 申请相机权限：android.permission.CAMERA
         * 申请相册权限：android.permission.WRITE_EXTERNAL_STORAGE
         */
        JsBridge.callHandler('checkPermissions', 'android.permission.CAMERA,android.permission.WRITE_EXTERNAL_STORAGE', (res) => {
          const obj = JSON.parse(res)
          const { result } = obj
          if (result) {
            setTimeout(() => {
              JsBridge.callHandler('requestPermissions', 'android.permission.CAMERA,android.permission.WRITE_EXTERNAL_STORAGE', (res) => {
                console.log(res)
              })
            }, 500);
          }
        })
      }
    })
  }
}
</script>

<style lang="scss" scoped>
.app {
  height: 100%;
}
</style>